#ifndef _CURVE_COMPLEX_INCLUDED
#define _CURVE_COMPLEX_INCLUDED

#include "mask.h"
#include <math.h>
#define MAXPTS	    (200)
#define VERYSMALL   (1.0e-12)

//ellipse related
void ellipse(double La, double Lb, double w=-1);
void pie_ellipse(double La, double Lb, double a0, double da);
void arc_ellipse(double La, double Lb, double a0, double da, double w);
void pie_ellipse_f(double La, double Lb, double a0, double da);
void arc_ellipse_f(double La, double Lb, double a0, double da, double w);

//
void pie_parabolic_f(double f, double a0, double da);
void pie_hyperbolic_f(double La, double f, double a0, double da);
void arc_parabolic_f(double f, double a0, double da, double w);
void arc_hyperbolic_f(double La, double f, double a0, double da, double w);
void arc_spiral_Archi(double Ca, double Cb, double a0, double da, double w);


typedef double (*FUNC)(double a, double c0, double c1);//function pointer
void arc_func(FUNC func, double a0, double da, double w, double c0, double c1=0);
void pie_func(FUNC func, double a0, double da, double c0, double c1=0, double x0=0, double y0=0);

//defined function for arc_func and pie_func.
double func_ellipse(double a, double La, double Lb);
double func_ellipse_f(double a, double La, double f);
double func_circle(double a, double r, double c1=0);
double func_parabolic_f(double a, double f, double c1=0);
double func_hyperbolic_f(double a, double La, double f);
double func_spiral_Archi(double a, double Ca, double Cb);
double func_spiral_log(double a, double Ca, double Cb);

/*for python wrapper of arc_func and pie_func
#ifdef SWIG

%typemap(in) PyObject *pyFunc {
  if (!PyCallable_Check($input)) {
      PyErr_SetString(PyExc_TypeError, "Need a callable object!");
      return NULL;
  }
  $1 = $input;
}

%inline %{

static PyObject *pyFunc_polar = NULL;
static double PyCallback_polar(double a, double c0, double c1)
{
   PyObject *func, *arglist;
   PyObject *result;
   
   func = (PyObject *) pyFunc_polar;               // Get Python function
   arglist = Py_BuildValue("(ddd)",a, c0, c1);             // Build argument list
   result = PyEval_CallObject(func,arglist);     // Call Python
   Py_DECREF(arglist);                           // Trash arglist
   Py_XDECREF(result);
   if (result) {                                 // If no errors, return double
     return PyFloat_AsDouble(result);
   }
   else {
     PyErr_SetString(PyExc_TypeError,"wrong output from callback function");  
   }
}

void arc_func(PyObject *pyFunc, double a0, double da, double w, double c0, double c1=0){
  pyFunc_polar = pyFunc;
  Py_XDECREF(pyFunc_polar);          // Dispose of previous callback //
  Py_XINCREF(pyFunc);         // Add a reference to new callback //    
  return arc_func(PyCallback_polar, a0, da, w, c0, c1);
}

void pie_func(PyObject *pyFunc, double a0, double da, double c0, double c1=0, double x0=0, double y0=0){
  pyFunc_polar = pyFunc;
  Py_XDECREF(pyFunc_polar);          // Dispose of previous callback /
  Py_XINCREF(pyFunc);         // Add a reference to new callback /    
  return pie_func(PyCallback_polar, a0, da, c0, c1, x0, y0);
}
%}
#endif
*/

#endif /* _MASK_INCLUDED */



